package com.thunbu.thunbu_meeting_system

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.LinearGradient
import android.graphics.Shader
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.TextView
import androidx.annotation.ColorInt


/**
 *Created by Chaolue.Fan on 2021/5/14
描述:
 */


/**
 * 设置文字渐变
 */
fun TextView.changeTextViewStyle(@ColorInt color0: Int, @ColorInt color1: Int) {
    val mLinearGradient = LinearGradient(0f, 0f,
        paint.textSize * text.length, 0f,
        color0, color1, Shader.TileMode.CLAMP)
    paint.shader = mLinearGradient
    invalidate()
}

/**
 * 软键盘隐藏
 */
fun View.hideSoftInput(context: Context) {
    val token = windowToken
    if (token != null) {
        val im = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
        im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS)
    }
}
